package com.yifei.converter.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifei.model.bo.system.UserBO;
import com.yifei.model.bo.system.UserFromBO;
import com.yifei.model.entity.system.SysUser;
import com.yifei.model.form.system.UserForm;
import com.yifei.model.vo.system.UserInfoVO;
import com.yifei.model.vo.system.UserPageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @Description: 用户对象转换器
 * @Author: yiFei
 * @date: 2023/10/2 13:21
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

    // 解析 Page<UserBO> 中的 记录数据
    @Mappings({
            @Mapping(target = "genderLabel", expression = "java(com.yifei.base.IBaseEnum.getLabelByValue(bo.getGender() , com.yifei.model.enums.GenderEnum.class))")
    })
    UserPageVO bo2Vo(UserBO bo);

    Page<UserPageVO> bo2Vo(Page<UserBO> bo);

    // 当前用户转换为 UserInfoVO
    @Mappings({
            @Mapping(target = "userId", source = "id")
    })
    UserInfoVO toUserInfoVo(SysUser user);

    UserForm bo2Form(UserFromBO userFormData);
}
